#ifndef LED_H_
#define LED_H_
#include <targets/lpc2000.h>


#if (HW_ver==5)||(HW_ver==4)

#define LEDs_DIRPORT    FIO1DIR

#define LED1_PIN        27
#define LED1_SETPORT    FIO1SET
#define LED1_CLRPORT    FIO1CLR

#define LED2_PIN        28
#define LED2_SETPORT    FIO1SET
#define LED2_CLRPORT    FIO1CLR

#define LED3_PIN        29
#define LED3_SETPORT    FIO1SET
#define LED3_CLRPORT    FIO1CLR

//(1<<LED1_PIN)|(1<<LED2_PIN)|(1<<LED3_PIN)
#endif



#if HW_ver==5
#define led_enable()      {SCS|=1;LEDs_DIRPORT |= (1<<LED1_PIN)|(1<<LED2_PIN)|(1<<LED3_PIN); LED1_SETPORT = (1<<LED1_PIN)|(1<<LED2_PIN)|(1<<LED3_PIN);}
#define led_red_on()      (LED1_CLRPORT =  (1<<LED1_PIN))
#define led_red_off()     (LED1_SETPORT =  (1<<LED1_PIN))
#define led_yellow_on()   (LED2_CLRPORT =  (1<<LED2_PIN))
#define led_yellow_off()  (LED2_SETPORT =  (1<<LED2_PIN))
#define led_green_on()    (LED3_CLRPORT =  (1<<LED3_PIN))
#define led_green_off()   (LED3_SETPORT =  (1<<LED3_PIN))


#elif HW_ver==4
#define led_enable()      {SCS|=1;LEDs_DIRPORT |= (1<<LED1_PIN)|(1<<LED2_PIN)|(1<<LED3_PIN); LED1_SETPORT = (1<<LED1_PIN)|(1<<LED2_PIN)|(1<<LED3_PIN);}
#define led_red_on()      (LED1_SETPORT =  (1<<LED1_PIN))
#define led_red_off()     (LED1_CLRPORT =  (1<<LED1_PIN))
#define led_yellow_on()   (LED2_SETPORT =  (1<<LED2_PIN))
#define led_yellow_off()  (LED2_CLRPORT =  (1<<LED2_PIN))
#define led_green_on()    (LED3_SETPORT =  (1<<LED3_PIN))
#define led_green_off()   (LED3_CLRPORT =  (1<<LED3_PIN))

#elif HW_ver==1
#define led_enable()      {FIO3DIR |= 0x07000000; FIO3SET = 0x07000000;}

#define led_red_on()      (FIO3CLR =  0x04000000)
#define led_red_off()     (FIO3SET =  0x04000000)
#define led_yellow_on()   (FIO3CLR =  0x02000000)
#define led_yellow_off()  (FIO3SET =  0x02000000)
#define led_green_on()    (FIO3CLR =  0x01000000)
#define led_green_off()   (FIO3SET =  0x01000000)
#else
#error Incorrect HW version
#endif


#endif /* LED_H_ */